package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSeneitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "敏感词管理",tags = "敏感词管理API")
@RequestMapping("/api/v1/sensitive")
@RestController
public class AdSensitiveController {
    @Autowired
    AdSeneitiveService adSeneitiveService;

    @ApiOperation(value = "敏感词查询")
    @PostMapping("/list")
    public ResponseResult findAdSensitiveByPage(@RequestBody SensitiveDTO sensitiveDTO){
        return adSeneitiveService.findAllSensitive(sensitiveDTO);
    }

    @ApiOperation(value = "敏感词添加")
    @PostMapping("/save")
    public ResponseResult insertSensitive(@RequestBody AdSensitive adSensitive){
        return adSeneitiveService.insertSensitive(adSensitive);
    }
    @ApiOperation(value = "敏感词修改")
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive){
        return adSeneitiveService.updateSensitive(adSensitive);
    }
    @ApiOperation(value = "敏感词删除")
    @DeleteMapping("/delete/{id}")
    public ResponseResult updateSensitive(@PathVariable("id") Integer id){
        return adSeneitiveService.deleteSensitive(id);
    }
    @ApiOperation(value = "查询所有敏感词")
    @PostMapping("/sensitives")
    public ResponseResult<List<String>> selectAllSensitive(){
        return adSeneitiveService.selectAllSensitive();
    }
}
